/**
 * 
 */
package com.shark.app.common.validate;

import com.shark.app.persistent.entity.TWmFinanceSysMenuEntity;

import java.io.File;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

/**
 * @author lenovo
 * @description
 * @date 2016年8月17日
 */
public class Test {


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		File f = new File("D:/project/py/calc.py");
		System.out.println(f.getPath());
		
		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();    
        Validator validator = factory.getValidator();    
    
        Entity entity = new Entity();    
        entity.setAge(12);    
        entity.setName("admin");    
        
        TWmFinanceSysMenuEntity menu = new TWmFinanceSysMenuEntity();
        menu.setIcon("12345678901234567890");
        
        Set<ConstraintViolation<TWmFinanceSysMenuEntity>> menuConstraintViolations = validator.validate(menu);    
        for (ConstraintViolation<TWmFinanceSysMenuEntity> constraintViolation : menuConstraintViolations) {    
            System.out.println("对象属性:"+constraintViolation.getPropertyPath());    
            System.out.println("国际化key:"+constraintViolation.getMessageTemplate());    
            System.out.println("错误信息:"+constraintViolation.getMessage());    
        }
        System.out.println("===================================");
        Set<ConstraintViolation<Entity>> constraintViolations = validator.validate(entity);    
        for (ConstraintViolation<Entity> constraintViolation : constraintViolations) {    
            System.out.println("对象属性:"+constraintViolation.getPropertyPath());    
            System.out.println("国际化key:"+constraintViolation.getMessageTemplate());    
            System.out.println("错误信息:"+constraintViolation.getMessage());    
        }    
	}

}
